import { defineStore } from 'pinia'
import {ref} from 'vue'

export const useCartStore = defineStore('cart', () => {
    //声明数据state
    const items = ref([])
    //actions
    const addItems = (item) => {
        items.push(item)
    }
    const removeItems = (index) => {
        items.splice(index,1)
    }
    const clear = () => {
        items = []
    }
    return {
        items,
        removeItems,
        clear,
        addItems
    }
})